package com.homework;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

public class FutureTask01 {

    public static void main(String[] args) throws Exception {
        long start = System.currentTimeMillis();

        System.out.println("Main Thread Start!");

        ExecutorService executor = Executors.newSingleThreadExecutor();
        FutureTask<String> future = new FutureTask<>(new Task(1));
        executor.submit(future);

        System.out.println("异步处理结果为：" + future.get());

        System.out.println("使用时间：" + (System.currentTimeMillis() - start) + " ms");

        executor.shutdown();
        System.out.println("Main Thread End!");
    }

}
